package com.icen.utils.comm;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;

/**
 * Notification Utils Class
 * 
 * @author IcenHan
 * 
 */
public class NotifyUtils {

	@SuppressWarnings("deprecation")
	public static void showNotification(Context context, int id, int icon,
			String title, String contentText, boolean isCanCancel,
			PendingIntent contentIntent) {
		NotificationManager notifyManager = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		Notification notification = new Notification(icon, title,
				System.currentTimeMillis());
		notification.defaults |= Notification.DEFAULT_SOUND
				| Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS;
		if (isCanCancel) {
			notification.flags |= Notification.FLAG_AUTO_CANCEL;
		} else {
			notification.flags |= Notification.FLAG_NO_CLEAR;
		}

		notification.setLatestEventInfo(context, title, contentText,
				contentIntent);
		notifyManager.notify(id, notification);
	}

	public static void delNotification(Context context, int id) {
		NotificationManager notifyManager = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		notifyManager.cancel(id);
	}
}
